// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, expressionValue
/**
 * File comment: not quite working
 */
// $codepro.audit.disable numericLiterals
package edu.gatech.oad.project.presentation;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;

import edu.gatech.oad.project.networking.clientSessions.PatientSessionClient;

/**
 * This class is a panel that allows the user
 * to interact with the GUI to schedule an
 * appointment.
 * 
 * @author Group 17
 * @version 1
 */
public class AppScheduler extends JPanel {
  
  /**
   * Field driver: holds the driver connected to the GUI
   */
  private final Driver driver;
  
  /**
   * Field lblAppointmentScheduler: label
   */
  private final JLabel lblAppointmentScheduler;
  
  /**
   * Field lblDate: label
   */
  private final JLabel lblDate;
  
  /**
   * Field lblTime: label
   */
  private final JLabel lblTime;
  
  /**
   * Field lblNewLabel: label
   */
  private final JLabel lblNewLabel;
  
  /**
   * Field lblReason: label
   */
  private final JLabel lblReason;
  
  /**
   * Field comboBox: options for dates
   */
  private final JComboBox comboBox;
  
  /**
   * Field comboBox_1: options for times
   */
  private final JComboBox comboBox_1;
  
  /**
   * Field comboBox_2: options for doctors
   */
  private final JComboBox comboBox_2;
  
  /**
   * Field reason: text field for user to write reason for appointment
   */
  private final JTextField reason;
  
  /**
   * Field btnRequestAppointment: submit request button
   */
  private final JButton btnRequestAppointment;
  
  /**
   * Field btnBackToHome: back button
   */
  private final JButton btnBackToHome;
  
  /**
   * Field date: holds appointment date
   */
  private int date = 101;
  
  /**
   * Field time: holds appointment time
   */
  private int time = 0000;
  
  /**
 * Field rawHours: holds the hours
 */
private int rawHours = 0000;
  
  /**
   * Field doctor: holds appointment doctor
   */
  private String doctor;
  
  /**
   * Field appReason: holds appointment reason
   */
  private String appReason;
  
  /**
   * Field comboBox_am_pm: am/pm option
   */   
  private final JComboBox comboBox_am_pm;
  
  /**
   * Field ampm: determins am/pm 
   */
  private String ampm;

  /**
 * Field comboBox_days: field for the days
 */
private final JComboBox comboBox_days;

 /**
  * Constructor.
  * 
  * @param driver the Driver connected to the GUI
  */
 public AppScheduler(Driver driver) { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.constructorsOnlyInvokeFinalMethods -->
   this.driver = driver;
  final GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[]{0, 0, 0, 66, 0, 0};
  gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
  gridBagLayout.rowWeights = new double[]{0.0, 0.0, 
          0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);
  
  lblAppointmentScheduler = new JLabel("Schedule an Appointment");
  lblAppointmentScheduler.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
  final GridBagConstraints gbc_lblAppointmentScheduler = new GridBagConstraints();
  gbc_lblAppointmentScheduler.insets = new Insets(0, 0, 5, 5);
  gbc_lblAppointmentScheduler.gridwidth = 5;
  gbc_lblAppointmentScheduler.gridx = 1;
  gbc_lblAppointmentScheduler.gridy = 1;
  add(lblAppointmentScheduler, gbc_lblAppointmentScheduler);
  
  lblDate = new JLabel("Date");
  final GridBagConstraints gbc_lblDate = new GridBagConstraints();
  gbc_lblDate.anchor = GridBagConstraints.EAST;
  gbc_lblDate.insets = new Insets(0, 0, 5, 5);
  gbc_lblDate.gridx = 1;
  gbc_lblDate.gridy = 3;
  add(lblDate, gbc_lblDate);
  
  final String[] dates = {"January", "February", "March", "April", "May", "June", "July",
                    "August", "September", "October", "November", "December"};
  comboBox = new JComboBox(dates);
  comboBox.addActionListener(new ComboBoxListenerMonth(this));
  final GridBagConstraints gbc_comboBox = new GridBagConstraints();
  gbc_comboBox.insets = new Insets(0, 0, 5, 5);
  gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
  gbc_comboBox.gridx = 2;
  gbc_comboBox.gridy = 3;
  add(comboBox, gbc_comboBox);
  
  final String[] days = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", 
                   "11", "12", "13",
                   "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", 
                   "25", "26", "27", "28", "29", "30", "31"};
  comboBox_days = new JComboBox(days);
  comboBox.addActionListener(new ComboBoxListenerDay(this));
  final GridBagConstraints gbc_comboBox_days = new GridBagConstraints();
  gbc_comboBox_days.insets = new Insets(0, 0, 5, 5);
  gbc_comboBox_days.fill = GridBagConstraints.HORIZONTAL;
  gbc_comboBox_days.gridx = 3;
  gbc_comboBox_days.gridy = 3;
  add(comboBox_days, gbc_comboBox_days);
  
  lblTime = new JLabel("Time");
  final GridBagConstraints gbc_lblTime = new GridBagConstraints();
  gbc_lblTime.anchor = GridBagConstraints.EAST;
  gbc_lblTime.insets = new Insets(0, 0, 5, 5);
  gbc_lblTime.gridx = 1;
  gbc_lblTime.gridy = 4;
  add(lblTime, gbc_lblTime);
  
  final String[] times = {"12:00", "12:30", "1:00", "1:30", "2:00", 
                    "2:30", "3:00", "3:30",
                    "4:00", "4:30", "5:00", "5:30", "6:00", "6:30", "7:00", "7:30",
                    "8:00", "8:30", "9:00", "9:30", "10:00", "10:30", "11:00", "11:30"};
  comboBox_1 = new JComboBox(times);
  comboBox_1.addActionListener(new ComboBoxListenerTime(this));
  final GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
  gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
  gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
  gbc_comboBox_1.gridx = 2;
  gbc_comboBox_1.gridy = 4;
  add(comboBox_1, gbc_comboBox_1);
  
  comboBox_am_pm = new JComboBox(new String[] {"AM", "PM"});
  comboBox_am_pm.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
          setAmpm((String) ((JComboBox) e.getSource()).getSelectedItem());
      }
  });
  final GridBagConstraints gbc_comboBox_ampm = new GridBagConstraints();
  gbc_comboBox_ampm.insets = new Insets(0, 0, 5, 5);
  gbc_comboBox_ampm.fill = GridBagConstraints.HORIZONTAL;
  gbc_comboBox_ampm.gridx = 3;
  gbc_comboBox_ampm.gridy = 4;
  add(comboBox_am_pm, gbc_comboBox_ampm);
  
  lblNewLabel = new JLabel("Doctor");
  final GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
  gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
  gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
  gbc_lblNewLabel.gridx = 1;
  gbc_lblNewLabel.gridy = 5;
  add(lblNewLabel, gbc_lblNewLabel);
  
  final String[] doctors = this.driver.getSession().getAllDoctors();
  //String[] doctors = {"Doctor 1","Doctor 2","Doctor 3"};
  comboBox_2 = new JComboBox(doctors);
  comboBox_2.addActionListener(new ComboBoxListener2(this));
  final GridBagConstraints gbc_comboBox_2 = new GridBagConstraints();
  gbc_comboBox_2.insets = new Insets(0, 0, 5, 5);
  gbc_comboBox_2.fill = GridBagConstraints.HORIZONTAL;
  gbc_comboBox_2.gridx = 2;
  gbc_comboBox_2.gridy = 5;
  add(comboBox_2, gbc_comboBox_2);
  
  lblReason = new JLabel("Reason");
  final GridBagConstraints gbc_lblReason = new GridBagConstraints();
  gbc_lblReason.insets = new Insets(0, 0, 5, 5);
  gbc_lblReason.gridx = 1;
  gbc_lblReason.gridy = 6;
  add(lblReason, gbc_lblReason);
  
  reason = new JTextField(30);
  reason.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      appReason = reason.getText();
    }
  });
  final GridBagConstraints gbc_txtReason = new GridBagConstraints();
  gbc_txtReason.gridheight = 3;
  gbc_txtReason.gridwidth = 2;
  gbc_txtReason.insets = new Insets(0, 0, 5, 5);
  gbc_txtReason.fill = GridBagConstraints.BOTH;
  gbc_txtReason.gridx = 2;
  gbc_txtReason.gridy = 6;
  add(reason, gbc_txtReason);
  reason.setColumns(30);
  
  btnRequestAppointment = new JButton("Request Appointment");
  btnRequestAppointment.addActionListener(new ButtonListener1(this));
  final GridBagConstraints gbc_btnRequestAppointment = new GridBagConstraints();
  gbc_btnRequestAppointment.insets = new Insets(0, 0, 5, 5);
  gbc_btnRequestAppointment.gridx = 2;
  gbc_btnRequestAppointment.gridy = 9;
  add(btnRequestAppointment, gbc_btnRequestAppointment);
  
  btnBackToHome = new JButton("Back to Home");
  btnBackToHome.addActionListener(new ButtonListener2(this));
  final GridBagConstraints gbc_btnBackToHome = new GridBagConstraints();
  gbc_btnBackToHome.insets = new Insets(0, 0, 5, 5);
  gbc_btnBackToHome.gridx = 3;
  gbc_btnBackToHome.gridy = 9;
  add(btnBackToHome, gbc_btnBackToHome);
 } // end constructor method
 
 /**
  * Get the Driver.
  * 
  * @return the Driver connected to the GUI
  */
 public Driver getDriver() {
   return this.driver;
 } // end getDriver method
 
 /**
  * Get the appointment date.
  * 
  * @return the int representing the appointment date
  */
 public int getDate() {
   return this.date;
 } // end getDate method
 
 /**
  * Set the appointment date.
  * 
  * @param date the int representing the new appointment date
  */
 public void setDate(int date) {
   this.date = date;
 } // end setDate method
 
 /**
  * Get the appointment time.
  * 
  * @return the int representing the appointment time
  */
 public int getTime() {
   return this.time;
 } // end getTime method
 
 /**
  * Set the appointment time.
  * 
  * @param time the int representing the new appointment time
  */
 public void setTime(int time) {
   this.time = time;
 } // end setTime method
 
 /**
  * Get the appointment doctor.
  * 
  * @return the String representing the appointment doctor
  */
 public String getDoctor() {
   return this.doctor;
 } // end getDoctor method
 
 /**
  * Set the appointment doctor.
  * 
  * @param doctor the String representing the new appointment doctor
  */
 public void setDoctor(String doctor) {
   this.doctor = doctor;
 } // end setDoctor method
 
 /**
  * Get the appointment reason.
  * 
  * @return the String representing the appointment reason
  */
 public String getReason() {
   return this.appReason;
 } // end getReason method
 
 /**
 * @param rawHours the rawHours to set
 */
public void setRawHours(int rawHours) {
    this.rawHours = rawHours;
}

/**
 * @return the rawHours
 */
public int getRawHours() {
    return rawHours;
}

/**
 * @param ampm the ampm to set
 */
public void setAmpm(String ampm) {
    this.ampm = ampm;
}

/**
 * @return the ampm
 */
public String getAmpm() {
    return ampm;
}

/**
  * This private inner class implements ActionListener for comboBox.
  * 
  * @author Group 17
  * @version 1
  */
 private class ComboBoxListenerMonth implements ActionListener {
   /**
    * Field appScheduler: The AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ComboBoxListenerMonth(AppScheduler appScheduler){
     this.appScheduler = appScheduler;
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e) { // $codepro.audit.disable cyclomaticComplexity
     final String item = (String) ((JComboBox) e.getSource()).getSelectedItem();
     if(item.equals("January")){
       this.appScheduler.setDate(date | (1 << 2));
     }
     else if(item.equals("February")) {
       this.appScheduler.setDate(date | (2 << 2));
     }
     else if(item.equals("March")) {
       this.appScheduler.setDate(date | (3 << 2));
     }
     else if(item.equals("April")) {
       this.appScheduler.setDate(date | (4 << 2));
     }
     else if(item.equals("May")) {
       this.appScheduler.setDate(date | (5 << 2));
     }
     else if(item.equals("June")) {
       this.appScheduler.setDate(date | (6 << 2));
     }
     else if(item.equals("July")) {
       this.appScheduler.setDate(date | (7 << 2));
     }
     else if(item.equals("August")) {
       this.appScheduler.setDate(date | (8 << 2));
     }
     else if(item.equals("September")) {
       this.appScheduler.setDate(date | (9 << 2));
     }
     else if(item.equals("October")) {
       this.appScheduler.setDate(date | (10 << 2));
     }
     else if(item.equals("November")) {
       this.appScheduler.setDate(date | (11 << 2));
     }
     else {
         this.appScheduler.setDate(date | (12 << 2));
     }
   } // end actionPerformed method
 } // end ComboBoxListener class

 /**
  * This private inner class implements ActionListener for comboBox_1.
  * 
  * @author Group 17
  * @version 1
  */
 private class ComboBoxListenerDay implements ActionListener {
   /**
    * Field appScheduler: the AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ComboBoxListenerDay(AppScheduler appScheduler) {
     this.appScheduler = appScheduler;
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e){ // $codepro.audit.disable 
     final String day = (String) ((JComboBox) e.getSource()).getSelectedItem();
     if(day.equals("1")) {
       this.appScheduler.setDate(date | 1);
     }
     else if(day.equals("2")) {
       this.appScheduler.setDate(date | 2);
     }
     else if(day.equals("3")) {
       this.appScheduler.setDate(date | 3);
     }
     else if(day.equals("4")) {
         this.appScheduler.setDate(date | 4);
     }
     else if(day.equals("5")) {
         this.appScheduler.setDate(date | 5);
     }
     else if(day.equals("6")) {
         this.appScheduler.setDate(date | 6);
     }
     else if(day.equals("7")) {
         this.appScheduler.setDate(date | 7);
     }
     else if(day.equals("8")) {
         this.appScheduler.setDate(date | 8);
     }
     else if(day.equals("9")) {
         this.appScheduler.setDate(date | 9);
     }
     else if(day.equals("10")) {
         this.appScheduler.setDate(date | 10);
     }
     else if(day.equals("11")) {
         this.appScheduler.setDate(date | 11);
     }
     else if(day.equals("12")) {
         this.appScheduler.setDate(date | 12);
     }
     else if(day.equals("13")) {
         this.appScheduler.setDate(date | 13);
     }
     else if(day.equals("14")) {
         this.appScheduler.setDate(date | 14);
     }
     else if(day.equals("15")) {
         this.appScheduler.setDate(date | 15);
     }
     else if(day.equals("16")) {
         this.appScheduler.setDate(date | 16);
     }
     else if(day.equals("17")) {
         this.appScheduler.setDate(date | 17);
     }
     else if(day.equals("18")) {
         this.appScheduler.setDate(date | 18);
     }
     else if(day.equals("19")) {
         this.appScheduler.setDate(date | 19);
     }
     else if(day.equals("20")) {
         this.appScheduler.setDate(date | 20);
     }
     else if(day.equals("21")) {
         this.appScheduler.setDate(date | 21);
     }
     else if(day.equals("22")) {
         this.appScheduler.setDate(date | 22);
     }
     else if(day.equals("23")) {
         this.appScheduler.setDate(date | 23);
     }
     else if(day.equals("24")) {
         this.appScheduler.setDate(date | 24);
     }
     else if(day.equals("25")) {
         this.appScheduler.setDate(date | 25);
     }
     else if(day.equals("26")) {
         this.appScheduler.setDate(date | 26);
     }
     else if(day.equals("27")) {
         this.appScheduler.setDate(date | 27);
     }
     else if(day.equals("28")) {
         this.appScheduler.setDate(date | 28);
     }
     else if(day.equals("29")) {
         this.appScheduler.setDate(date | 29);
     }
     else if(day.equals("30")) {
         this.appScheduler.setDate(date | 30);
     }
     else {
         this.appScheduler.setDate(date | 31);
     }
     
   } // end actionPerformed method
 } // end ComboBoxListener1 class
 
 /**
  * This private inner class implements ActionListener for comboBox_1.
  * 
  * @author Group 17
  * @version 1
  */
 private class ComboBoxListenerTime implements ActionListener {
   /**
    * Field appScheduler: the AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ComboBoxListenerTime(AppScheduler appScheduler) {
     this.appScheduler = appScheduler;
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e) { // $codepro.audit.disable cyclomaticComplexity
   
     final String time = (String) ((JComboBox) e.getSource()).getSelectedItem();
     if(time.equals("12:00")) {
       this.appScheduler.setRawHours(1200);
     }
     else if(time.equals("12:30")) {
       this.appScheduler.setRawHours(1230);
     }
     else if(time.equals("1:00")) {
       this.appScheduler.setRawHours(100);
     }
     else if(time.equals("1:30")) {
       this.appScheduler.setRawHours(130);
     }
     else if(time.equals("2:00")) {
       this.appScheduler.setRawHours(200);
     }
     else if(time.equals("2:30")) {
       this.appScheduler.setRawHours(230);
     }
     else if(time.equals("3:00")) {
       this.appScheduler.setRawHours(300);
     }
     else if(time.equals("3:30")) {
       this.appScheduler.setRawHours(330);
     }
     else if(time.equals("4:00")) {
       this.appScheduler.setRawHours(400);
     }
     else if(time.equals("4:30")) {
       this.appScheduler.setRawHours(430);
     }
     else if(time.equals("5:00")) {
       this.appScheduler.setRawHours(500);
     }
     else if(time.equals("5:30")) {
       this.appScheduler.setRawHours(530);
     }
     else if(time.equals("6:00")) {
       this.appScheduler.setRawHours(600);
     }
     else if(time.equals("6:30")) {
       this.appScheduler.setRawHours(630);
     }
     else if(time.equals("7:00")) {
       this.appScheduler.setRawHours(700);
     }
     else if(time.equals("7:30")) {
       this.appScheduler.setRawHours(730);
     }
     else if(time.equals("8:00")) {
       this.appScheduler.setRawHours(800);
     }
     else if(time.equals("8:30")) {
       this.appScheduler.setRawHours(830);
     }
     else if(time.equals("9:00")) {
       this.appScheduler.setRawHours(900);
     }
     else if(time.equals("9:30")) {
       this.appScheduler.setRawHours(930);
     }
     else if(time.equals("10:00")) {
       this.appScheduler.setRawHours(1000);
     }
     else if(time.equals("10:30")) {
       this.appScheduler.setRawHours(1030);
     }
     else if(time.equals("11:00")) {
       this.appScheduler.setRawHours(1100);
     }
     else if(time.equals("11:30")) {
       this.appScheduler.setRawHours(1130);
     }
     
   } // end actionPerformed method
 } // end ComboBoxListener1 class
 
 /**
  * This private inner class implements ActionListener for comboBox_2.
  * 
  * @author Group 17
  * @version 1
  */
 private class ComboBoxListener2 implements ActionListener {
   /**
    * Field appScheduler: the AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ComboBoxListener2(AppScheduler appScheduler) {
     this.appScheduler = appScheduler;
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e) {
     final String doctor = (String) ((JComboBox) e.getSource()).getSelectedItem();
     this.appScheduler.setDoctor(doctor);
   } // end actionPerformed method
 } // end ComboBoxListener2 class
 
 /**
  * This private inner class implements ActionListener for btnRequestAppointment.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener1 implements ActionListener {
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private final Driver driver;
   
   /**
    * Field appScheduler: the AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ButtonListener1(AppScheduler appScheduler) {
     this.appScheduler = appScheduler;
     this.driver = appScheduler.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e) {
    /**int month = Calendar.getInstance().get(Calendar.MONTH);
    int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
    int year = Calendar.getInstance().get(Calendar.YEAR);
    System.out.println(date);
    System.out.println(rawHours);
    int userDay = Integer.parseInt(Integer.toString(date).substring(2,4));
    System.out.println(userDay);
    if ((date >> 2) < (month + 1)) {
        year++;
    }
    else if (((date >> 2) == (month + 1)) && (userDay < day)) {
        year++;
    }
    int ldate = (year << 4) | date;
    System.out.println(ldate);
    time = rawHours;
    if(this.appScheduler.getAmpm().equals("PM")) {
        if ((time != 1200) && (time != 1230)) {
            time += 1200;
        }
    }
    else {
        if ((time == 1200)) {
            time = 0000;
        }
        else if (time == 1230){
            time = 30;
        }
    }
    
**/
     if(((PatientSessionClient) this.driver.getSession()).isAvailable(
             date, time, doctor)) {
       ((PatientSessionClient) this.driver.getSession()).makeAppointment(
               date, time, doctor, appReason);
       this.appScheduler.btnRequestAppointment.setText("Request submitted.");
     }
     else {
       this.appScheduler.btnRequestAppointment.setText(
               "Appointment time is unavailable.");
     }
   } // end actionPerformed method
 } // end ButtonListener1 class
 
 /**
  * This private inner class implements ActionListener for btnBackToHome.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener2 implements ActionListener {
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private final Driver driver;
   
   /**
    * Field appScheduler: the AppScheduler being used
    */
   private final AppScheduler appScheduler;
   
   /**
    * Constructor.
    * 
    * @param appScheduler the AppScheduler being used
    */
   private ButtonListener2(AppScheduler appScheduler) {
     this.appScheduler = appScheduler;
     this.driver = appScheduler.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e) {
     this.driver.getFrame().setContentPane(new PatientHome(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener2 class
} // end AppScheduler class